package com.itheima.test;


import com.itheima.domain.GirlFriend;

import java.util.Arrays;
import java.util.Comparator;


public class Test03 {
    public static void main(String[] args) {

        GirlFriend xiaoshihsi = new GirlFriend("xiaoshihsi", 18, 1.67);
        GirlFriend xiaodandan = new GirlFriend("xiaodandan", 19, 1.70);
        GirlFriend xiaohuihui = new GirlFriend("xiaohuihui", 18, 1.78);

        GirlFriend[] arr = {xiaodandan, xiaohuihui, xiaoshihsi};

        Arrays.sort(arr, (o1, o2) -> {
                    double temp = o1.getAge() - o2.getAge();
                    temp = temp == 0 ? o1.getHeight() - o2.getHeight() : temp;
                    temp = temp == 0 ? o1.getName().compareTo(o2.getName()) : temp;

                    if (temp > 0) return 1;
                    else if (temp < 0) return -1;
                    else return 0;
                }
        );

        System.out.println(Arrays.toString(arr));

    }
}
